home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / XML Utilities / Professional Programmer XSL IDE / Xselerator25.msi / Data.Cab / F27082_EmployeesToHTML.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2001-10-04  |  2.2 KB  |  67 lines

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!-- ===========================================================
  3.   Category:       XSLT
  4.   Sub-category:   xsl:output
  5.   Author:         David Silverlight
  6.                   HeadGeek@xmlpitstop.com
  7.   Created:        2001-05-16
  8.   Description:-
  9.     This stylesheet processes a set of XML elements and displays
  10.     the result in HTML.  This is accomplished using the output
  11.     method of HTML.
  12.  =============================================================== -->
  13. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  14.   <xsl:output method="html" />
  15.  
  16.   <xsl:template match="/">
  17.     <html>
  18.       <head>
  19.         <title>Stylesheet Example</title>
  20.         <style type="text/css"><![CDATA[
  21.         H1 {COLOR: red; FONT-FAMILY: Arial; FONT-SIZE: 14pt;}
  22.         H2 {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
  23.         .head {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 14pt;}
  24.         .subhead {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
  25.         .text {COLOR: black; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
  26.         TH {COLOR: white; FONT-FAMILY: Arial; background-color: darkblue;}
  27.         TD {COLOR: darkblue; FONT-FAMILY: Arial}
  28.         TR { background-color: beige; }
  29.         BODY { background-color: beige; }
  30.         ]]></style>
  31.       </head>
  32.       <body>
  33.         <xsl:apply-templates />
  34.       </body>
  35.     </html>
  36.   </xsl:template>
  37.  
  38.   <!-- Template for "employees" elements -->
  39.   <xsl:template match="employees">
  40.     <h1>Displaying Employees with output as HTML</h1>
  41.     <!-- Table Header Creation -->
  42.     <table border="1">
  43.       <tr>
  44.         <th>Department</th>
  45.         <th>Name</th>
  46.         <th>Hourly Rate</th>
  47.         <th>Programming Language</th>
  48.       </tr>
  49.       <xsl:for-each select="employee">
  50.         <tr>
  51.           <td>
  52.             <xsl:value-of select="department" />
  53.           </td>
  54.           <td>
  55.             <xsl:value-of select="employeename" />
  56.           </td>
  57.           <td>
  58.             <xsl:value-of select="hourlyrate" />
  59.           </td>
  60.           <td>
  61.             <xsl:value-of select="primarylanguage" />
  62.           </td>
  63.         </tr>
  64.       </xsl:for-each>
  65.     </table>
  66.   </xsl:template>
  67. </xsl:stylesheet>